package com.buptlogistics.creditinvestigation.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.buptlogistics.creditinvestigation.R;
import com.buptlogistics.creditinvestigation.activity.CommonActivity;
import com.buptlogistics.creditinvestigation.app.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 我的消息
 */
public class CircleMineFragment extends BaseFragment {


    private View view;
    private ListView ll_info;
    private List<String> infoList = new ArrayList<>();
    private ArrayAdapter<String> infoAdapter;


    public CircleMineFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_circle_mine, container, false);
        initViews();
        initEvents();
        return view;
    }

    protected void initViews() {
        ll_info = (ListView) findViewById(R.id.ll_circle_mine);
    }

    protected void initEvents() {
        infoList.add("批号为20150911羊肉到期");
        infoList.add("张三 应收账款20151226融资申请");
        infoAdapter = new ArrayAdapter<String>(CircleMineFragment.this.getActivity(), android.R.layout
                .simple_expandable_list_item_1, infoList);
        ll_info.setAdapter(infoAdapter);
        ll_info.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                switch (i) {
                    case 0: {
                        Bundle data = new Bundle();
                        data.putInt("fragmentType", 10);
                        // 创建一个Intent
                        Intent intent = new Intent(CircleMineFragment.this.getActivity(),
                                CommonActivity.class);
                        intent.putExtras(data);
                        // 启动intent对应的Activity
                        startActivity(intent);
                        break;
                    }
                    case 1: {
                        Bundle data = new Bundle();
                        data.putInt("fragmentType", 5);
                        // 创建一个Intent
                        Intent intent = new Intent(CircleMineFragment.this.getActivity(),
                                CommonActivity.class);
                        intent.putExtras(data);
                        // 启动intent对应的Activity
                        startActivity(intent);
                        break;
                    }

                }

            }
        });
    }

    protected View findViewById(int id) {
        return view.findViewById(id);
    }


}
